using System;
using System.Collections;
using System.Text;
using System.Data;
using System.Security.Cryptography;

using PlugNT.Safe;
using PlugNT.Database;
using PlugNT.Cms.Custom;
using PlugNT.Cms.BLL;
using PlugNT.Cms.Model;
using PlugNT.App.Bbs.Model;

namespace PlugNT.App.Bbs.BLL
{
    public class Section
    {

        private static readonly PlugNT.App.Bbs.DAL.Section dal = new PlugNT.App.Bbs.DAL.Section();






        public SectionInfo GetSectionInfo(int sysModelId, int channelId)
        {
            return dal.GetSectionInfo(sysModelId, channelId);
        }





        public int GetTopicTodayCount(int sysModelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetTopicTodayCount(sysModelId);
        }
        public int GetTopicTodayCount(int sysModelId, int channelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetTopicTodayCount(sysModelId, channelId);
        }
        public int GetReplyTodayCount(int sysModelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetReplyTodayCount(sysModelId);
        }
        public int GetReplyTodayCount(int sysModelId, int channelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetReplyTodayCount(sysModelId, channelId);
        }


        public int GetTopicYesterdayCount(int sysModelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetTopicYesterdayCount(sysModelId);
        }
        public int GetReplyYesterdayCount(int sysModelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetReplyYesterdayCount(sysModelId);
        }


        public int GetTopicCount(int sysModelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetTopicCount(sysModelId);
        }
        public int GetTopicCount(int sysModelId, int channelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetTopicCount(sysModelId, channelId);
        }
        public int GetReplyCount(int sysModelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetReplyCount(sysModelId);
        }
        public int GetReplyCount(int sysModelId, int channelId)
        {
            return PlugNT.App.Bbs.DAL.Section.GetReplyCount(sysModelId, channelId);
        }







        public void RemoveTopicCount(int sysModelId, ArticleInfo aInfo)
        {
            PlugNT.App.Bbs.DAL.Section.RemoveTopicCount(sysModelId, aInfo.channel_id, true);
        }
        public void RemoveReplyCount(int sysModelId, ReplyInfo rInfo)
        {
            PlugNT.App.Bbs.DAL.Section.RemoveReplyCount(sysModelId, rInfo.channel_id, true);
        }
        public bool SetLastTopic(int sysModelId, ArticleInfo aInfo)
        {
            return PlugNT.App.Bbs.DAL.Section.SetLastTopic(sysModelId, aInfo.channel_id, aInfo.id, aInfo.title, aInfo.GetExtField("author").fieldValue, aInfo.addtime);
        }
        public bool SetLastReply(int sysModelId, ReplyInfo rInfo)
        {
            return PlugNT.App.Bbs.DAL.Section.SetLastReply(sysModelId, rInfo.id, rInfo.article_id, rInfo.title, rInfo.username, rInfo.addtime);
        }


     


        public void RemoveTopicCount2(int sysModelId, ArticleInfo aInfo)
        {
            PlugNT.App.Bbs.DAL.Section.UserTopic(sysModelId,aInfo.GetExtField("author").fieldValue, false);
            PlugNT.App.Bbs.DAL.Section.RemoveTopicCount(sysModelId, aInfo.channel_id, true);
        }

        public bool SetLastTopic2(int sysModelId, ArticleInfo aInfo)
        {
            PlugNT.App.Bbs.DAL.Section.UserTopic(sysModelId,aInfo.GetExtField("author").fieldValue, true);
            PlugNT.App.Bbs.DAL.Section.RemoveTopicCount(sysModelId, aInfo.channel_id, true);
            return PlugNT.App.Bbs.DAL.Section.SetLastTopic(sysModelId, aInfo.channel_id, aInfo.id, aInfo.title, aInfo.GetExtField("author").fieldValue, aInfo.addtime);
        }








        public bool Add(SectionInfo model)
        {
            return dal.Add(model);
        }


        public bool Update(SectionInfo model)
        {
            return dal.Update(model);
        }


        public bool Delete(int sysModelId, int channelId)
        {
            return dal.Delete(sysModelId, channelId);
        }



        public DataTable GetList(int sysModelId, string noList)
        {
            return dal.GetList(sysModelId, noList);
        }


        public DataTable GetViewList(int sysModelId, string noList)
        {
            return dal.GetViewList(sysModelId, noList);
        }


        public DataTable GetBindList(int sysModelId, string noList)
        {
            return dal.GetBindList(sysModelId, noList);
        }




    }
}

